#!/usr/bin/env perl

print <<END
set term postscript color portrait
set size 2, 1
set pm3d map
unset colorbox
unset xtics
END
;

my $row = 0;
my @length;
my @label;
my %labelno;
my @lines;
while ( <> ) {
  chomp;
  my ($label, @data) = split "\t";
  if ( $row == 0 ) {
    @length = @data;
  }
  else {
    $label =~ s/\"//g;
    push @label, $label;
    $labelno{$label} = $row;
    foreach my $i ( 0 .. $#data ) {
      push @lines, "$row\t$length[$i]\t$data[$i]\n";
    }
    push @lines, "\n";
  }
  $row++;
}
print "set ytics (" . join(", ", map {qq("$_" $labelno{$_})} @label) . ")\n";
print "splot '-' u 2:1:3 notitle\n";
print join "", @lines;
print "e\n";
